<?php

include 'inc/fen_fns.php';
//include('inc/db.php');

sec_session_start(); 

$rememberPassword = $_POST['rememberPassword'];

$expire=time()+60*60*24*30;


if(isset($_POST['email'], $_POST['p'])) {
	$email = $_POST['email'];
	$password = $_POST['p']; 
	
	if(login($email, $password, $mysqli) == true) {
		// Login success
		if ($rememberPassword == 'on') {
			setcookie("username", $_POST['email'], $expire);
		}
		header('Location: ./member.php');
	} else {
		// Login failed
		header('Location: ./index.php?error=1');
	}
} else {
	
	echo 'Invalid Request';
}
